package com.kefu.call.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.kefu.common.mybatis.KefuMapper;
import com.kefu.call.model.CallGateway;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@DS("fs")
public interface CallGatewayMapper extends KefuMapper<CallGateway>{

    // 将 company 列中的逗号分隔字符串转换为数组,检查 tenantId 是否在转换后的数组中 (类似于MySQL中 FIND_IN_SET 的功能)
    @Select("SELECT memo FROM gateway WHERE #{tenantId} = ANY (string_to_array(company, ','))")
    List<String> findByCompany(String tenantId);

    @Select("SELECT f_oid FROM gateway WHERE #{tenantId} = ANY (string_to_array(company, ','))")
    List<String> findIdByCompany(String tenantId);
}